﻿
@{
    Layout = null;
    ViewData["Title"] = "Index";
}
<script src="~/js/vue.js"></script>
<script src="~/js/axios.js"></script>
<script src="~/element-ui/lib/index.js"></script>
<link rel="stylesheet" href="~/element-ui/lib/theme-chalk/index.css" />
<div id="app">
    <font color="black">
        您正在做的业务是：人力资源--招聘管理--职位发布管理--职位发布登记 
    </font>
    <el-descriptions :column="2" border>
        <el-descriptions-item>
            <template slot="label">
                I、II、III级机构
            </template>
            <el-cascader expand-trigger="hover"
                         :options="HeBingData"
                         :props="cascaderProps"
                         v-model="selectedKeys"
                         v-on:change="parentCateChanged"
                         clearable
                         change-on-select
                         ref="casc">
            </el-cascader>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                招聘类型
            </template>
            <el-select v-model="engage_type" placeholder="请选择招聘类型">
                <el-option label="校园招聘" value="校园招聘"></el-option>
                <el-option label="社会招聘" value="社会招聘"></el-option>
            </el-select>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                职位分类
            </template>
            <el-select v-model="major_kind_name" placeholder="请选择职位分类" v-on:change="getZhiWeiFenLei">
                <el-option v-for="item in zhiWeiFenLei"
                           :key="item.major_kind_id"
                           :lable="item.major_kind_name"
                           :value="[item.major_kind_id,item.major_kind_name]">
                </el-option>
            </el-select>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                职位名称
            </template>
            <el-select v-model="major_name" placeholder="请选择职位名称" v-on:change="getZhiWeiName">
                <el-option v-for="item in zhiWeiName"
                           :key="item.mak_id"
                           :lable="item.major_name"
                           :value="[item.major_id,item.major_name]">
                </el-option>
            </el-select>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                招聘人数
            </template>
            <el-input v-model="human_amount" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                截止日期
            </template>
            <el-date-picker type="date" placeholder="选择日期" v-model="deadline" style="width: 100%;"></el-date-picker>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                登记人
            </template>
            <el-input v-model="register" readonly="readonly"></el-input>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                登记时间
            </template>
            <el-input v-model="regist_time" width="20px" readonly="readonly"></el-input>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                职位描述
            </template>
            <el-input type="textarea" v-model="major_describe"></el-input>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                招聘要求
            </template>
            <el-input type="textarea" v-model="engage_required"></el-input>
        </el-descriptions-item>
    </el-descriptions>
    <span class="anniu">
        <el-button type="primary" size="small" v-on:click="TiJiao()">提交</el-button>
        <el-button type="primary" size="small" v-on:click="QingChu()">清除</el-button>
    </span>
</div>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            HeBingData: [],
            cascaderProps: {
                value: "id",
                label: "name",
                children: "children",
            },
            selectedKeys: [],
            first_kind_id: "",
            first_kind_name: "",
            second_kind_id: "",
            second_kind_name: "",
            third_kind_id: "",
            third_kind_name: "",
            major_kind_id: "",
            major_kind_name: "",
            major_id: "",
            major_name: "",
            engage_type: "",
            human_amount: "",
            deadline: "",
            register: sessionStorage.getItem('userName'),
            regist_time: "",
            major_describe: "",
            engage_required: "",
            item: "",
            zhiWeiFenLei: [],
            zhiWeiName: [],
        },
        methods: {
            //一二三级下拉框 查询方法
            FindHeBing() {
                axios.get("/ZhiWeiFaBuDengJi/HeBing").then(res => {
                    this.HeBingData = res.data;
                })
            },
            //一二级下拉框  改变事件
            parentCateChanged() {
                //选中值有就大于0
                if (this.selectedKeys.length > 0) {
                    //获取键
                    this.key = this.selectedKeys;
                    //console.info(this.selectedKeys);
                    //获取值
                    this.zhi = this.$refs["casc"].getCheckedNodes()[0].pathLabels;
                    //console.info(this.$refs["casc"].getCheckedNodes()[0].pathLabels);
                }
            },
            //查询职位分类
            FindZhiWeiFenLei() {
                axios.get("/ZhiWeiFaBuDengJi/ZhiWeiFenLei").then(res => {
                    this.zhiWeiFenLei = res.data;
                })
            },
            //查询职位名称
            FindZhiWeiName() {
                axios.get("/ZhiWeiFaBuDengJi/ZhiWeiName").then(res => {
                    this.zhiWeiName = res.data;
                })
            },
            //职位分类下拉框改变事件
            getZhiWeiFenLei(e) {
                let [major_kind_id, major_kind_name] = e;
                this.major_kind_id = major_kind_id;
                this.major_kind_name = major_kind_name;
            },
            //职位名称下拉框改变事件
            getZhiWeiName(e) {
                let [major_id, major_name] = e;
                this.major_id = major_id;
                this.major_name = major_name;
            },
            //点击提交 提交成功清空
            TiJiao() {
                //console.info(this.key[0]);
                //console.info(this.zhi[0]);
                //console.info(this.key[1]);
                //console.info(this.zhi[0]);
                //console.info(this.key[2]);
                //console.info(this.zhi[2]);
                //console.info(this.major_kind_id);
                //console.info(this.major_kind_name);
                //console.info(this.major_id);
                //console.info(this.major_name);
                //console.info(this.human_amount);
                //console.info(this.engage_type);
                //console.info(this.deadline);
                //console.info(this.register);
                //console.info(this.regist_time);
                //console.info(this.major_describe);
                //console.info(this.engage_required);
                axios.post("/ZhiWeiFaBuDengJi/Insert",{
                    first_kind_id: this.key[0],
                    first_kind_name: this.zhi[0],
                    second_kind_id: this.key[1],
                    second_kind_name: this.zhi[1],
                    third_kind_id: this.key[2],
                    third_kind_name: this.zhi[2],
                    major_kind_id: this.major_kind_id,
                    major_kind_name: this.major_kind_name,
                    major_id: this.major_id,
                    major_name: this.major_name,
                    human_amount: this.human_amount,
                    engage_type: this.engage_type,
                    deadline: this.deadline,
                    register: this.register,
                    regist_time: this.regist_time,
                    major_describe: this.major_describe,
                    engage_required: this.engage_required
                }).then(res => {
                    if (res.data > 0) {
                        alert("添加成功");
                        //清空
                        this.QingChu();
                        
                    } else {
                        alert("添加失败");
                    }
                }).catch(err =>{
                    console.info(err)
                })
            },
            //清空文本框
            QingKong() {
                this.major_kind_id = "";
                this.major_kind_name = "";
                this.major_id = "";
                this.major_name = "";
                this.engage_type = "";
                this.major_kind_name = "";
                this.major_name = "";
                this.human_amount = "";
                this.deadline = "";
                this.regist_time = "";
                this.major_describe = "";
                this.engage_required = "";
            },
            //清空级联下拉框
            clear(){
                this.$refs.casc.$refs.panel.clearCheckedNodes()
            },
            //点击清楚按钮 清空
            QingChu() {
                this.QingKong();
                this.clear();
            },
            //时间
            tick() {
                var d = new Date();
                var y = d.getFullYear();
                var moth = d.getMonth() + 1;
                var date = d.getDate();
                var h = d.getHours();
                var m = d.getMinutes();
                var s = d.getSeconds();
                var hh = 20 - 1 - h;
                var mm = 60 - 1 - m;
                var ss = 60 - s;
                if (hh > 0) {
                    mm = mm + 60 * hh;
                }
                if (moth < 10) {
                    moth = "0" + moth;
                }
                if (date < 10) {
                    date = "0" + date;
                }
                if (h < 10) {
                    h = "0" + h;
                }
                if (m < 10) {
                    m = "0" + m;
                }
                if (s < 10) {
                    s = "0" + s;
                }
                if (mm < 10) {
                    mm = "0" + mm;
                }
                if (ss < 10) {
                    ss = "0" + ss;
                }
                this.regist_time = y + " - " + moth + " - " + date + " " + h + ": " + m + ": " + s;
            },
        },
        mounted() {
            this.FindHeBing();
            this.FindZhiWeiFenLei();
            this.FindZhiWeiName();
            window.onload=this.tick;
            var out=window.setInterval(this.tick, 1000);
        }
    });
</script>
<style>
    .el-descriptions-item__label.is-bordered-label {
        background: white;
        color: black;
    }

    .anniu {
        position: fixed;
        top: 388px;
        left: 874px;
    }
</style>
